package com.panfeng.xcloud.boss.provider.assets.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.panfeng.xcloud.boss.provider.assets.dto.request.QueryWalletTransLogPageReqDTO;
import com.panfeng.xcloud.boss.provider.assets.dto.response.QueryWalletTransLogPageRespDTO;
import com.panfeng.xcloud.boss.provider.assets.service.IWalletTransLogService;
import com.panfeng.xcloud.boss.provider.assets.web.vo.request.QueryWalletTransLogPageReqVO;
import com.panfeng.xcloud.boss.provider.assets.web.vo.response.QueryWalletTransLogPageRespVO;
import com.panfeng.xcloud.common.core.page.PageResponse;
import com.panfeng.xcloud.common.core.utils.ConvertUtils;
import com.panfeng.xcloud.common.core.web.vo.PageResponseVO;
import com.panfeng.xcloud.common.core.web.vo.ResponseVO;
import com.panfeng.xcloud.common.security.annotation.MethodValidate;
import com.panfeng.xcloud.common.security.annotation.NotNeedAccess;
import com.panfeng.xcloud.common.security.web.support.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 相关交易日志模块
 *
 * @author xiaobo
 * @version 1.0
 * @since 2021-03-24
 */
//@ApiIgnore
@RestController
@RequestMapping("assets/walletTransLog")
@Api(tags = {"相关交易日志模块"})
@Slf4j
public class WalletTransLogController extends BaseController {

    @Autowired
    private IWalletTransLogService iWalletTransLogService;

    /**
     * 查询相关交易日志
     *
     * @param queryWalletTransLogPageReqVO
     * @param bindingResult
     * @return
     */
    @NotNeedAccess
    @MethodValidate
    @PostMapping(value = "/queryWalletTransLog", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询相关交易日志(肖博)", httpMethod = "POST", notes = "查询相关交易日志(肖博)")
    public ResponseVO<PageResponseVO<QueryWalletTransLogPageRespVO>> queryWalletTransLog(@RequestBody @Valid QueryWalletTransLogPageReqVO queryWalletTransLogPageReqVO, BindingResult bindingResult) {
        logger.info(">>>> 当前queryWalletTransLog请求参数：{} <<<", (null != queryWalletTransLogPageReqVO ? JSONObject.toJSONString(queryWalletTransLogPageReqVO) : ""));
        QueryWalletTransLogPageReqDTO queryWalletTransLogPageReqDTO = ConvertUtils.convert(queryWalletTransLogPageReqVO, QueryWalletTransLogPageReqDTO.class);
        PageResponse<QueryWalletTransLogPageRespDTO> pageDTO = iWalletTransLogService.queryWalletTransLog(queryWalletTransLogPageReqDTO);
        PageResponseVO<QueryWalletTransLogPageRespVO> pageVO = ConvertUtils.convertPage(pageDTO, QueryWalletTransLogPageRespVO.class);
        logger.info(">>>> 当前queryWalletTransLog响应内容：{} <<<", (null != pageVO ? JSONObject.toJSONString(pageVO) : ""));
        return ResponseVO.with(pageVO);
    }

}
